#pragma once

#include "MessageSystem.h"
#include "IGameState.h"
#include "Player.h"
#include "ObjectManager.h"
#include "TileManager.h"
#include "Enemy.h"
#include "LaserDoor.h"

// Bitmap font
#include "BitmapFont.h"

class Emitter;
class Level;
class Console;
class Chest;
class Hazard;

enum PausedBox	{XBOX = 272, PAUSE_RESUME = 204, PAUSE_OPTIONS = 259, PAUSE_OUIT = 309};


class GamePlayState : public IGameState 
{
	friend class Dungeon;

public:
	static GamePlayState* GetInstance();

	static void MessageProc(Message* msg);

	bool win;
	bool lose;
	bool twoPlayer;
	bool inMinigame;
	bool inUpgradeState;
	bool inCutscene;
	bool inOptions;

	virtual void Enter();

	virtual void Exit();

	virtual bool Input();

	virtual void Update(float elapsed);

	virtual void Render();

	void ShipLevelStart();

	Player* GetPlayer() const	{return player;}
	Player* GetPlayer2() const	{return player2;}
	int		GetCamX() const		{return camX;}
	int		GetCamY() const		{return camY;}
	Level* GetLevel()			{return curLevel;}
	inline void SetCam(int x, int y) { camX = x; camY = y; }

	int GetExplodeSoundID()		{return Enemy_Explode;}
	int GetRepairBotSound()		{return RepairBotMove;}
	int GetRepairSound()		{return RepairBotHeal;}

	void SetMuliplayer(bool tmp)	{twoPlayer = tmp;}

	// Get the sound for the pickups
	inline int GetPickupSound(void) { return PickupSound; }

	// Sorcery
	enum Magic { MAGIC, MOREMAGIC };
	void DoMagic(Magic amount);

	// Add a chest
	void AddChest(Chest* newChest);

	// Add a level hazard
	void AddHazard(Hazard* hazard);

	// Ready the next dungeon
	inline void NextDungeon(void) { ++CurrentDungeon; }


	TCHAR pauseStr	[11];
	TCHAR resumeStr	[15];
	TCHAR optionStr	[10];
	TCHAR quitStr	[20];

	// TCHARs for pickups
	TCHAR metalStr[10];
	TCHAR circuitStr[15];

	int GetCurDungeon() const	{return CurrentDungeon;};
	void SetCurDungeon(int d)	{CurrentDungeon = d;}

	void SetSaveSlot(int s)		{saveSlot = s;}

	void SetNewGame(bool g)		{newGame = g;}
	void SetFromMain(bool m)	{fromMain = m;}

	bool onShip;

	void SetPause(bool p)		{paused = p;}

private:
	GamePlayState();

	GamePlayState(GamePlayState& game);

	GamePlayState& operator=(GamePlayState& game);

	virtual ~GamePlayState();

	void HUDmagic();

	// Wrapper/Managers
	ObjectManager* om;
	TileManager* tm;
	EmitterManager* em;

	// Temps to test
	int x;
	int y;
	int sound;
	int karl;
	int kitty;
	Emitter* e;
	Emitter* e2;

	int loadingScreen;

	//Entity* playerEntity;
	Player* player;
	Player* player2;

	int player1Wait;
	int player2Wait;

	vector<Enemy*> enemies;

	// pause
	bool paused;
	int pauseY;

	// Bitmap font
	CBitmapFont* GroupFont;
	int	FontImageID;

	Level* curLevel;

	// All the chests in the level
	vector<Chest*> chestList;

	// All the level hazards
	vector<Hazard*> LevelHazards;

	// The doors
	vector<LaserDoor*> Doors;

	Console* testconsole;

	// Sounds
	int musicVolume;
	int SFXVolume;
	int cursorX;
	int cursorY;
	float soundTimer;
	int PickupSound;

	// NEW HUD
	int hudIconsID;
	int pausedID;
	int pauseBoxID;

	// Camera Position
	int camX;
	int camY;

	// Which dungeon the player(s) will enter next
	int CurrentDungeon;

	// Which Save Slot
	int saveSlot;

	// Sounds
	int unplugged;
	bool unplugOnce;
	int shipMusic;
	int researchMusic;
	int powerMusic;
	int militaryMusic;
	int recycleMusic;
	int tutorialMusic;
	//sfx
	int Enemy_Explode;

	bool newGame;
	bool fromMain;
	bool inPopUp;
	int curPopUp;

	// Tutorial Images
	int popUp;
	int buttonA;
	int buttonX;
	int buttonB;
	int buttonLB;
	int buttonRB;
	int leftThumb;
	int buttonBack;
	int buttonY;

	bool hasPopped[8];
	bool after0;
	int oldX;

	int RepairBotMove;
	int RepairBotHeal;

	int pausePlayerNum;

};
